Prevent dragging groups into groups. Fixes #8706
[adiumx.git] / Plugins / Purple Service / ESPurpleICQAccountViewController.m
blob62c25e6b0dd612c8d1aeae8a440385402899e3b9
1 /* 
2  * Adium is the legal property of its developers, whose names are listed in the copyright file included
3  * with this source distribution.
4  * 
5  * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6  * General Public License as published by the Free Software Foundation; either version 2 of the License,
7  * or (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
11  * Public License for more details.
12  * 
13  * You should have received a copy of the GNU General Public License along with this program; if not,
14  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15  */
17 #import "ESPurpleICQAccountViewController.h"
18 #import "ESPurpleICQAccount.h"
19 #import <Adium/AIAccount.h>
20 #import <AIUtilities/AIPopUpButtonAdditions.h>
21 #import <AIUtilities/AIMenuAdditions.h>
23 @interface ESPurpleICQAccountViewController (PRIVATE)
24 - (NSMenu *)encodingMenu;
25 - (void)addEncodingItemsWithNames:(NSArray *)inArray withTitle:(NSString *)inTitle toMenu:(NSMenu *)menu;
26 @end
27                                                                                    
28 @implementation ESPurpleICQAccountViewController
30 - (NSString *)nibName{
31     return @"ESPurpleICQAccountView";
35 - (void)awakeFromNib
37         [super awakeFromNib];
38         
39         [popUp_encoding setMenu:[self encodingMenu]];   
42 //Configure controls
43 - (void)configureForAccount:(AIAccount *)inAccount
45     [super configureForAccount:inAccount];
46         [popUp_encoding selectItemWithRepresentedObject:[account preferenceForKey:KEY_ICQ_ENCODING
47                                                                                                                                                 group:GROUP_ACCOUNT_STATUS]];
50 //Save controls
51 - (void)saveConfiguration
53     [super saveConfiguration];
54         [account setPreference:[[popUp_encoding selectedItem] representedObject]
55                                         forKey:KEY_ICQ_ENCODING
56                                          group:GROUP_ACCOUNT_STATUS];   
59 - (NSMenu *)encodingMenu
61         NSMenu          *menu = [[NSMenu alloc] init];
62         NSArray         *nameArray;
63         NSString        *title;
64         
65         //We'll do custom enabling/disabling and not change it after then, so we don't want auto menuItem validation
66         [menu setAutoenablesItems:NO];
67         
68         title = @"European languages";
69         nameArray = [NSArray arrayWithObjects:
70                 @"ASCII",
71                 @"ISO-8859-1",
72                 @"ISO-8859-2",
73                 @"ISO-8859-3",
74                 @"ISO-8859-4",
75                 @"ISO-8859-5",
76                 @"ISO-8859-7",
77                 @"ISO-8859-9",
78                 @"ISO-8859-10",
79                 @"ISO-8859-13",
80                 @"ISO-8859-14",
81                 @"ISO-8859-15",
82                 @"ISO-8859-16",
83                 @"KOI8-R",
84                 @"KOI8-U", 
85                 @"KOI8-RU",
86                 @"CP1250",
87                 @"CP1251",
88                 @"CP1252",
89                 @"CP1253",
90                 @"CP1254",
91                 @"CP1257",
92                 @"CP850",
93                 @"CP866",
94                 @"MacRoman",
95                 @"MacCentralEurope",
96                 @"MacIceland",
97                 @"MacCroatian",
98                 @"MacRomania",
99                 @"MacCyrillic",
100                 @"MacUkraine",
101                 @"MacGreek",
102                 @"MacTurkish",
103                 @"Macintosh",
104                 nil];
105         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
106         
107         title = @"Semitic languages";
108         nameArray = [NSArray arrayWithObjects:
109                 @"ISO-8859-6",
110                 @"ISO-8859-8",
111                 @"CP1255",
112                 @"CP1256",
113                 @"CP862",
114                 @"MacHebrew",
115                 @"MacArabic",
116                 nil];
117         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
118         
119         title = @"Japanese";
120         nameArray = [NSArray arrayWithObjects:
121                 @"EUC-JP",
122                 @"SHIFT_JIS",
123                 @"CP932",
124                 @"ISO-2022-JP",
125                 @"ISO-2022-JP-2",
126                 @"ISO-2022-JP-1",
127                 nil];
128         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
130         title = @"Chinese";
131         nameArray = [NSArray arrayWithObjects:
132                 @"EUC-CN",
133                 @"HZ",
134                 @"GBK",
135                 @"GB18030",
136                 @"EUC-TW",
137                 @"BIG5",
138                 @"CP950",
139                 @"BIG5-HKSCS",
140                 @"ISO-2022-CN",
141                 @"ISO-2022-CN-EXT",
142                 nil];
143         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
144         
145         title = @"Korean";
146         nameArray = [NSArray arrayWithObjects:
147                 @"EUC-KR",
148                 @"CP949",
149                 @"ISO-2022-KR",
150                 @"JOHAB",
151                 nil];
152         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
154         title = @"Armenian";
155         nameArray = [NSArray arrayWithObjects:
156                 @"ARMSCII-8",
157                 nil];
158         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
159         
160         title = @"Georgian";
161         nameArray = [NSArray arrayWithObjects:
162                 @"Georgian-Academy",
163                 @"Georgian-PS",
164                 nil];
165         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
166         
167         title = @"Tajik";
168         nameArray = [NSArray arrayWithObjects:
169                 @"KOI8-T",
170                 nil];
171         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
173         title = @"Thai";
174         nameArray = [NSArray arrayWithObjects:
175                 @"TIS-620",
176                 @"CP874",
177                 @"MacThai",
178                 nil];
179         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
180         
181         title = @"Laotian";
182         nameArray = [NSArray arrayWithObjects:
183                 @"MuleLao-1",
184                 @"CP1133",
185                 nil];
186         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
187         
188         title = @"Vietnamese";
189         nameArray = [NSArray arrayWithObjects:
190                 @"VISCII",
191                 @"TCVN",
192                 @"CP1258",
193                 nil];
194         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
196         /*
197                 Platform specifics
198                 HP-ROMAN8, NEXTSTEP
199                 
200                 Full Unicode
201                 UTF-8 
202          */
203         
204         return [menu autorelease];
207 - (void)addEncodingItemsWithNames:(NSArray *)inArray withTitle:(NSString *)inTitle toMenu:(NSMenu *)menu
209         NSEnumerator    *enumerator;
210         NSString                *name;
211         NSMenuItem              *menuItem;
212     BOOL                        canIndent;
213         
214     menuItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:inTitle
215                                                                                                                                         target:nil
216                                                                                                                                         action:nil
217                                                                                                                          keyEquivalent:@""];
218         [menuItem setEnabled:NO];
219         [menu addItem:menuItem];
220         
221         canIndent = [menuItem respondsToSelector:@selector(setIndentationLevel:)];
222         
223         enumerator = [inArray objectEnumerator];
224         while ((name = [enumerator nextObject])) {
225                 menuItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:name
226                                                                                                                                                 target:nil
227                                                                                                                                                 action:nil
228                                                                                                                                  keyEquivalent:@""];
229                 [menuItem setRepresentedObject:name];
230                 if (canIndent) [menuItem setIndentationLevel:1];
231                 
232                 [menu addItem:menuItem];
233         }
236 @end